<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<jsp:include page="parts/adminFooter.jsp"></jsp:include>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
	<!-- js开始部分 -->
	<script type="text/javascript">
		var createMenu = function(data){
			var str = "";
			$.each(data,function(i,n){
				str += '<div title="'+n.text+'" '+
				'data-options="iconCls:\''+n.icon+'\'" '+
				'style="overflow:auto;padding:0px;'+
				'background: #f0f9fd;"><ul class="menuson">';
				$.each(n.children,function(j,sn){
					var url = "${ctx}/"+sn.url;
					str+='<li><cite></cite>'+
					'<a href="#" icon="'+sn.icon+'" '+
					'url="'+url+'">'+sn.text+'</a></li>';
				});
				str+='</ul></div>';
			});
			console.log(JSON.stringify(str));
			$('#aa').html(str);
		}
		$(function(){
			var rid = ${user.roleId};
			$.ajax({
				type:'post',
				dataType:'json',
				url:'${ctx}/menu/createMenu/'+rid,
				async:false,
				success:function(data){
					data = $.parseJSON(data);
					createMenu(data);
				}
			});
		});
		//监听标签动作
		$(".menuson li").click(function(){
			/* 移除样式 */
			$(".menuson li.active").removeClass("active");
			/* 获取当前标签对象，添加样式 */
			$(this).addClass("active");
			$(".nav li a.selected").removeClass("selected");
			var a = $(".menuson li.active a");
			var title = a.html();
			var url = a.attr("url");
			var icon = a.attr("icon");
			//菜单栏的切换
			addTabs(title,url,icon);
		});
	</script>
	
	<div class="lefttop"><span></span>系统菜单</div>
	<div id="aa" class="easyui-accordion" data-options="fit:false"></div>
</body>
</html>